package com.huawei.appgallery.forum.posts.view;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import androidx.annotation.Nullable;
import com.huawei.appgallery.forum.base.ui.ForumActivity;
import com.huawei.appgallery.forum.posts.api.IPostDetailProtocol;
import com.huawei.appgallery.forum.posts.api.IPostDetailResult;
import com.huawei.hmf.annotation.ActivityDefine;
import o.bqx;
import o.bse;
import o.btb;
import o.bzd.a;
import o.cbh;
import o.doo;
import o.evk;
import o.fho;
import o.fiu;
import o.fiv;
import o.fjb;
import o.fjc;
import o.fjf;
import o.fjo;
import o.fjq;

@ActivityDefine(alias = "post.detail.activity", protocol = IPostDetailProtocol.class, result = IPostDetailResult.class)
public class PostDetailTransgerActivity extends ForumActivity {
    private fiv ͺ = fiv.ॱ(this);

    public void onCreate(@Nullable Bundle bundle) {
        requestWindowFeature(1);
        super.onCreate(bundle);
        if (bundle != null) {
            finish();
            return;
        }
        View view = new View(this);
        view.setAlpha(0.0f);
        setContentView(view);
        getWindow().setBackgroundDrawableResource(a.ˈ);
        IPostDetailProtocol iPostDetailProtocol = (IPostDetailProtocol) this.ͺ.ॱ();
        if (iPostDetailProtocol == null) {
            bqx.ॱ("PostDetailTransgerActivity", "protocol is null!");
            finish();
        } else if (!iPostDetailProtocol.getNeedComment()) {
            ॱ(iPostDetailProtocol);
        } else if (btb.ˊ(this, iPostDetailProtocol.getPostStatus(), false)) {
            ˊ(iPostDetailProtocol);
        } else {
            ॱ(-1, -1, 1);
            finish();
        }
    }

    private void ॱ(IPostDetailProtocol iPostDetailProtocol) {
        fjb ˎ = fho.ˏ().ˋ("Posts").ˎ("post.detail.inner.activity");
        IPostDetailProtocol iPostDetailProtocol2 = (IPostDetailProtocol) ˎ.ˊ();
        iPostDetailProtocol2.setUri(iPostDetailProtocol.getUri());
        iPostDetailProtocol2.setSourceType(iPostDetailProtocol.getSourceType());
        iPostDetailProtocol2.setNeedComment(iPostDetailProtocol.getNeedComment());
        iPostDetailProtocol2.setErrorCode(iPostDetailProtocol.getErrorCode());
        iPostDetailProtocol2.setDomainId(iPostDetailProtocol.getDomainId());
        iPostDetailProtocol2.setStayTimeKey(iPostDetailProtocol.getStayTimeKey());
        iPostDetailProtocol2.setPositionToCommentCard(iPostDetailProtocol.getPositionToCommentCard());
        fiu.ˊ().ॱ((Context) this, ˎ, new fjc<IPostDetailResult>(this) {
            final /* synthetic */ PostDetailTransgerActivity ˋ;

            {
                this.ˋ = r1;
            }

            public /* synthetic */ void ˎ(int i, Object obj) {
                ˋ(i, (IPostDetailResult) obj);
            }

            public void ˋ(int i, IPostDetailResult iPostDetailResult) {
                ((PostDetailTransgerActivity) ˊ()).ˏ(i, iPostDetailResult);
            }
        });
    }

    private void ˏ(int i, IPostDetailResult iPostDetailResult) {
        if (i == -1 && iPostDetailResult != null) {
            ॱ(iPostDetailResult.getLike(), iPostDetailResult.getLikeCount(), iPostDetailResult.getRtnCode());
        } else if (i != 0 || iPostDetailResult == null) {
            setResult(i);
        } else {
            ॱ(-1, -1, iPostDetailResult.getRtnCode());
        }
        finish();
    }

    private void ˊ(final IPostDetailProtocol iPostDetailProtocol) {
        if (doo.ˊ((Context) this)) {
            ((cbh) fho.ˏ().ˋ("User").ॱ(cbh.class)).ˎ(this, 15).ˏ(new fjq<Boolean>(this) {
                final /* synthetic */ PostDetailTransgerActivity ॱ;

                public void onComplete(fjo<Boolean> o_fjo_java_lang_Boolean) {
                    if (o_fjo_java_lang_Boolean.ˊ() && ((Boolean) o_fjo_java_lang_Boolean.ॱ()).booleanValue()) {
                        this.ॱ.ॱ(iPostDetailProtocol);
                        return;
                    }
                    bqx.ˏ("PostDetailTransgerActivity", "check user fail");
                    this.ॱ.ॱ(-1, -1, 1);
                    this.ॱ.finish();
                }
            });
            return;
        }
        evk.ˏ(getString(bse.ˏ.ˏ()));
        finish();
    }

    private void ॱ(int i, long j, int i2) {
        fjf ˊ = fjf.ˊ(this);
        IPostDetailResult iPostDetailResult = (IPostDetailResult) ˊ.ॱ();
        iPostDetailResult.setLike(i);
        iPostDetailResult.setLikeCount(j);
        iPostDetailResult.setRtnCode(i2);
        setResult(-1, ˊ.ˊ());
    }
}
